/*
 * @Description: 缺陷信息接口
 * @Author: Liu Zhiwang
 * @Date: 2021-04-13 20:19:54
 * @LastEditTime: 2021-09-28 14:02:53
 * @LastEditors: Huang Junjie
 */
import request from '@/utils/request'

// 查询列表信息
export function getListPage(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/cms' + query.unitCodeParams + '/defectInfo/') : '/cms/defectInfo/',
    url: '/cms/defectInfo/listPage',
    method: 'GET',
    params: params
  })
}

// 根据id查询信息
export function getInfoById(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/cms' + query.unitCodeParams + `/defectInfo/getById`) : `/cms/defectInfo/getById`,
    url: `/cms/defectInfo/getById`,
    method: 'GET',
    params: params
  })
}

// 新增/修改信息
export function addOrEditData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/cms' + query.unitCodeParams + '/defectInfo/base') : '/cms/defectInfo/base',
    url: '/cms/defectInfo/base',
    method: 'POST',
    data: params
  })
}

// 修改接触网的整改信息
export function cancelNumber(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/cms' + query.unitCodeParams + '/defectInfo/reform') : '/cms/defectInfo/reform',
    url: '/cms/defectInfo/reform',
    method: 'POST',
    data: params
  })
}

// 删除信息
export function deleteData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/cms' + query.unitCodeParams + `/defectInfo/${params.id}`) : `/cms/defectInfo/${params.id}`,
    url: `/cms/defectInfo/${params.id}`,
    method: 'DELETE'
  })
}

// 查询各个统计数
export function getCount(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/cms' + query.unitCodeParams + '/defectInfo/count') : '/cms/defectInfo/count',
    url: '/cms/defectInfo/count',
    method: 'GET',
    params: params
  })
}

//  模板导入
export function upload(query) {
  return request({
    url: `/cms/defectInfo/upload`,
    method: 'POST',
    data: query
  })
}

